<?php 
	class Activity extends CI_Controller{
		public function __construct(){
			parent::__construct();
		}
		
		public function news($str="",$type=""){
			//$str ="anwar_Ibrahim";
			$arr = array();
			$this->db->select("t2.pkid,t2.content_en,t2.title_en,t2.img");
			$this->db->from("mobile_customer t1");
			$this->db->join("mobile_activity t2", "t1.pkid=t2.customer_pkid");
			$this->db->where("t1.name",$str);
			$this->db->where("t2.status",1);
			if($type != ""){
				$this->db->where("t2.activity_type",$type);
			}
			$res = $this->db->get()->result_array();
			foreach ($res as $P){
				$tmp['pkid']		=$P['pkid'];
				$tmp['title']		=stripslashes($P['title_en']);
				//$tmp['desc']		=stripslashes($P['content_en']);
				$tmp['img']		=$P['img'];
				$arr[] = $tmp;
			}
			echo json_encode($arr);
		}
		
		public function news_detail($id=""){
			$this->db->where("pkid",$id);
			$row =$this->db->get("mobile_activity")->row();
			$tmp['title']		=stripslashes($row->title_en);
			$tmp['desc']		=stripslashes($row->content_en);
			$tmp['img']		=$row->img;
			$arr[] = $tmp; 
			echo json_encode($arr);
		}
		
		public function vdo($str="",$type=""){
			//$str ="anwar_Ibrahim";
			$arr = array();
			$this->db->select("t2.pkid,t2.url,t2.name_en,t2.img");
			$this->db->from("mobile_customer t1");
			$this->db->join("mobile_video t2", "t1.pkid=t2.customer_pkid");
			$this->db->where("t1.name",$str);
			$this->db->where("t2.status",1);
			if($type !=""){
				$this->db->where("t2.vdo_type",$type);
			}
			$res = $this->db->get()->result_array();
			foreach ($res as $P){
				$tmp['pkid']		=$P['pkid'];
				$tmp['title']		=stripslashes($P['name_en']);
				$tmp['url']			="http://".stripslashes($P['url']);
				$tmp['img']		=$P['img'];
				$arr[] = $tmp;
			}
			echo json_encode($arr);
		}
		
		public function gallery($str=""){
			//$str ="anwar_Ibrahim";
			$arr = array();
			if($str != null){
				$this->db->select("t1.pkid,t1.img,t1.img_big");
				$this->db->from("mobile_gallery t1");
				$this->db->join("mobile_customer t2","t1.customer_pkid=t2.pkid",'left');
				$this->db->where("t2.name",$str);
				$res = $this->db->get()->result_array();
				foreach ($res as $P){
					$tmp['pkid']			=$P['pkid'];
					$tmp['img']			=base_url().'media/gallery/'.$P['img'];
					$tmp['img_big']			=base_url().'media/gallery/'.$P['img_big'];
					$arr[] = $tmp;
				}
				echo json_encode($arr);
			}
		}
		
	}
?>